package com.sls.sys.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.page.Pagination;
import com.sls.sys.dao.PermissionDAO;
import com.sls.sys.pojo.PermissionInfo;
import com.sls.sys.pojo.PermissionInfoVO;
import com.sls.sys.querybean.PermissionQuery;

@Repository("permissionDAO")
public class PermissionDAOImpl extends SuperDAO<PermissionInfoVO> implements
		PermissionDAO {

	@Override
	public List<PermissionInfoVO> queryAll() {
		List<PermissionInfoVO> list = this.getSqlSession().selectList(
				"mybatis.xml.PermissionInfoMapper.queryAllPermissionInfo");
		return list;
	}
	
	@Override
	public void insertPermission(PermissionInfoVO p) {
		getSqlSession().insert("mybatis.xml.PermissionInfoMapper.insert", p);
	}
	@Override
	public void updatePermission(PermissionInfoVO p) {
		getSqlSession().update("mybatis.xml.PermissionInfoMapper.updateByserviceCode", p);
	}

	@Override
	public PermissionInfo queryInfoByServiceCode(String serviceCode) {
		PermissionInfo permission = this.getSqlSession().selectOne(
				"mybatis.xml.PermissionInfoMapper.queryPermissionInfoByServiceCode",
				serviceCode);
		return permission;
	}

	@Override
	public Pagination<PermissionInfoVO> queryPermission(
			PermissionQuery permissionQuery) {
		return this
				.queryPagination("mybatis.xml.PermissionInfoMapper.queryPermissionPage",
						"mybatis.xml.PermissionInfoMapper.queryPermissionNumber",
						permissionQuery);
	}

	@Override
	public void delete(String serviceCode) {
		this.getSqlSession().delete(
				"mybatis.xml.PermissionInfoMapper.deletePermissionInfoByServiceCode",
				serviceCode);
	}

}
